package run;

import lsieun.utils.FileUtils;

import java.io.File;

public class PathManager {
    public static String getJarPath() {
        return "D:/tmp/origin/BetterIntelliJ-1.15.jar";
    }

    public static String getOutputPath() {
        String user_dir = System.getProperty("user.dir");
        return user_dir + File.separator + "target";
    }

    public static String getClassDir() {
        String user_home = System.getProperty("user.home");
        return user_home + File.separator + "compare_class";
    }

    public static String backUpJar() {
        String jarPath = getJarPath();
        return backUpFile(jarPath);
    }

    public static String backUpFile(String filepath) {
        String newFilePath = getNewFilePath(filepath);
        System.out.println("Old Jar Path: " + filepath);
        System.out.println("New Jar Path: " + newFilePath);
        FileUtils.copy(filepath, newFilePath);
        return newFilePath;
    }

    public static String getNewFilePath(String jarPath) {
        File f = new File(jarPath);
        String filename = f.getName();

        String outputPath = getOutputPath();
        return outputPath + File.separator + filename;
    }

    public static void main(String[] args) {
        String filepath = getOutputPath();
        System.out.println(filepath);
    }
}
